package com.isunland.managesystem.ui;

import com.google.gson.Gson;
import com.isunland.managesystem.base.BaseNetworkDialogFragment;
import com.isunland.managesystem.common.ApiConst;
import com.isunland.managesystem.entity.CurrentUser;
import com.isunland.managesystem.entity.CustomerDialog;
import com.isunland.managesystem.entity.WareHouseOriginal;
import com.isunland.managesystem.entity.WareHouseOriginal.WareHouseContent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class WareHouseDialogFragment extends BaseNetworkDialogFragment {

  @Override public ArrayList<CustomerDialog> resolveResponse(String arg0) {
    ArrayList<CustomerDialog> list = new ArrayList<CustomerDialog>();
    WareHouseOriginal contractContentOriginal = new Gson().fromJson(arg0, WareHouseOriginal.class);

    List<WareHouseContent> dataList = contractContentOriginal.getRows();

    if (dataList == null || dataList.size() == 0) {

      return null;
    }
    for (int i = 0; i < dataList.size(); i++) {
      list.add(
          new CustomerDialog(dataList.get(i).getStorageName(), dataList.get(i).getStorageId()));
    }
    return list;
  }

  @Override public String getUrl() {
    return ApiConst.URL_WAREHOUSE;
  }

  @Override public HashMap<String, String> getparameters() {
    HashMap<String, String> params = new HashMap<String, String>();
    params.put("memberCode", CurrentUser.newInstance(getActivity()).getMemberCode().toString());
    params.put("isPaging", "0");
    params.put("dataStatus", "publish");
    return params;
  }
}
